<template>
  <div class="contact-container" :class="{ 'dark-mode': isDark }">
    <div class="contact-card">
      <!-- 标题部分 -->
      <div class="header-section">
        <h1 class="title">联系我们</h1>
        <p class="subtitle">让我们开始一段愉快的合作</p>
      </div>

      <!-- 个人信息展示 -->
      <div class="info-section">
        <div class="info-item" v-for="(info, index) in personalInfo" :key="index">
          <div class="icon-wrapper" :style="{ background: info.bgColor }">
            <component :is="info.icon" class="icon" />
          </div>
          <div class="info-text">
            <p class="label">{{ info.label }}</p>
            <a v-if="info.isLink" :href="info.linkPrefix + info.value" class="value link">
              {{ info.value }}
            </a>
            <p v-else class="value">{{ info.value }}</p>
          </div>
        </div>
      </div>

      <!-- 社交媒体连接 -->
      <div class="contact-methods">
        <h2 class="section-title">社交媒体</h2>
        <div class="method-grid">
          <a
            v-for="method in contactMethods"
            :key="method.name"
            :href="method.link"
            target="_blank"
            class="method-card"
            :class="{ 'method-card-hover': hoveredMethod === method.name }"
            @mouseenter="hoveredMethod = method.name"
            @mouseleave="hoveredMethod = ''"
          >
            <div class="method-icon" :style="{ background: method.bgColor }">
              <img
                v-if="method.name === 'Gitee'"
                src="https://gitee.com/favicon.ico"
                class="gitee-icon"
                alt="Gitee"
              />
              <component v-else :is="method.icon" class="icon" />
            </div>
            <div class="method-content">
              <p class="method-name">{{ method.name }}</p>
              <p class="method-desc">{{ method.desc }}</p>
            </div>
            <div class="method-arrow">
              <RightOutlined />
            </div>
          </a>
        </div>
      </div>

      <!-- 主题切换 -->
      <div class="theme-toggle" @click="toggleTheme" :class="{ 'theme-toggle-active': !isDark }">
        <BulbOutlined class="icon" />
        <span class="toggle-text">{{ isDark ? '切换亮色' : '切换暗色' }}</span>
      </div>
    </div>

    <!-- 背景动画元素 -->
    <div class="animated-bg">
      <div v-for="n in 5" :key="n" class="bg-circle" :style="getRandomStyle()"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import {
  UserOutlined,
  IdcardOutlined,
  MailOutlined,
  GithubOutlined,
  BulbOutlined,
  CodeOutlined,
  RightOutlined,
  PhoneOutlined,
  GlobalOutlined,
} from '@ant-design/icons-vue'

// 状态管理
const isDark = ref(true)
const hoveredMethod = ref('')

// 个人信息数据
const personalInfo = [
  {
    icon: UserOutlined,
    label: '昵称',
    value: '鹿七',
    bgColor: 'linear-gradient(135deg, #74ebd5 0%, #9face6 100%)',
    isLink: false,
  },
  {
    icon: IdcardOutlined,
    label: '姓名',
    value: '孔令原',
    bgColor: 'linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%)',
    isLink: false,
  },
  {
    icon: MailOutlined,
    label: '邮箱',
    value: '2693176405@qq.com',
    bgColor: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
    isLink: true,
    linkPrefix: 'mailto:',
  },
  {
    icon: PhoneOutlined,
    label: '电话',
    value: '+86 18883799646',
    bgColor: 'linear-gradient(135deg, #d299c2 0%, #fef9d7 100%)',
    isLink: true,
    linkPrefix: 'tel:',
  },
]

// 社交媒体数据
const contactMethods = [
  {
    name: 'Gitee',
    desc: '查看开源项目',
    icon: CodeOutlined,
    link: 'https://gitee.com/luqi269317',
    bgColor: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
  },
  {
    name: 'GitHub',
    desc: '关注最新动态',
    icon: GithubOutlined,
    link: 'https://github.com/konglingyuanluqi',
    bgColor: 'linear-gradient(135deg, #5ee7df 0%, #b490ca 100%)',
  },
  {
    name: '个人主页',
    desc: '了解更多信息',
    icon: GlobalOutlined,
    link: 'https://your-website.com',
    bgColor: 'linear-gradient(135deg, #c3cfe2 0%, #c3cfe2 100%)',
  },
]

// 主题切换
const toggleTheme = () => {
  isDark.value = !isDark.value
}

// 生成随机样式
const getRandomStyle = () => {
  const size = Math.random() * 200 + 100
  return {
    width: `${size}px`,
    height: `${size}px`,
    left: `${Math.random() * 100}%`,
    top: `${Math.random() * 100}%`,
    animationDelay: `${Math.random() * 2}s`,
    animationDuration: `${Math.random() * 10 + 10}s`,
  }
}
</script>

<style scoped lang="scss">
.contact-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, #1e1e2f 0%, #2c2c4a 100%);
  color: #fff;
  transition: all 0.5s ease;
  position: relative;
  overflow: hidden;

  &.dark-mode {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
  }
}

.contact-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 3rem;
  width: 100%;
  max-width: 800px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: cardFloat 4s ease-in-out infinite;
}

.header-section {
  text-align: center;
  margin-bottom: 3rem;

  .title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #74ebd5, #9face6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
  }
}

.info-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  transition: all 0.3s ease;

  &:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
  }
}

.icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;

  .icon {
    font-size: 24px;
    color: #fff;
  }
}

.info-text {
  flex: 1;

  .label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.3rem;
  }

  .value {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
  }

  .link {
    color: #74ebd5;
    text-decoration: none;
    position: relative;
    transition: all 0.3s ease;

    &::after {
      content: '';
      position: absolute;
      left: 0;
      bottom: -2px;
      width: 0;
      height: 2px;
      background: currentColor;
      transition: width 0.3s ease;
    }

    &:hover {
      color: #9face6;

      &::after {
        width: 100%;
      }
    }
  }
}

.contact-methods {
  .section-title {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 2rem;
    position: relative;

    &::after {
      content: '';
      position: absolute;
      bottom: -10px;
      left: 50%;
      transform: translateX(-50%);
      width: 60px;
      height: 3px;
      background: linear-gradient(90deg, #74ebd5, #9face6);
      border-radius: 3px;
    }
  }
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.method-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: #fff;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);

  &:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);

    .method-arrow {
      transform: translateX(5px);
      opacity: 1;
    }
  }
}

.method-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  .icon,
  .gitee-icon {
    font-size: 24px;
    color: #fff;
  }

  .gitee-icon {
    width: 24px;
    height: 24px;
    filter: brightness(10);
  }
}

.method-content {
  flex: 1;

  .method-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
  }

  .method-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
  }
}

.method-arrow {
  color: #74ebd5;
  opacity: 0;
  transition: all 0.3s ease;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;

  &:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  .icon {
    font-size: 18px;
    color: #fff;
  }

  .toggle-text {
    font-size: 14px;
    color: #fff;
  }
}

.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 0;
}

.bg-circle {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(45deg, rgba(116, 235, 213, 0.1), rgba(159, 172, 230, 0.1));
  animation: float 20s infinite linear;
}

@keyframes cardFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes float {
  0% {
    transform: translate(0, 0) rotate(0);
  }
  100% {
    transform: translate(100px, 100px) rotate(360deg);
  }
}

// 响应式设计
@media screen and (max-width: 768px) {
  .contact-container {
    padding: 1rem;
  }

  .contact-card {
    padding: 2rem;
    margin: 1rem;
  }

  .header-section {
    .title {
      font-size: 2rem;
    }
  }

  .info-section {
    grid-template-columns: 1fr;
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  .theme-toggle {
    top: 10px;
    right: 10px;
  }
}
</style>
